<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数节流</title>
    <style>
        html {
            height: 10000px;
        }
    </style>
</head>

<body>

</body>
<script>


    // var start = 0;
    // // console.log(Date.now());
    // window.onscroll = function () {
    //     var now = Date.now();
    //     if (now - start > 200) {
    //         start = now;
    //         console.log(window.scrollY);
    //     }
    // }


    window.addEventListener("scroll",(function(e){
        var start = 0;
        return function(){
            var now = Date.now();
            if(now-start>200){
                start = now;
                console.log(Math.round(window.scrollY));
            }
        }
    })())








</script>

</html>